<template>
  <div class="login">
    <div class="con">
      <h3 class="center line">登录</h3>
      <div class="line">
        <el-input placeholder="请输入账号" v-model="user.username" clearable></el-input>
      </div>
      <div class="line">
        <el-input placeholder="请输入密码" v-model="user.password" clearable show-password></el-input>
      </div>
      <div class="center">
        <el-button type="primary" @click="login">登录</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { reqLogin } from "../../request/api";
export default {
  components: {},
  data() {
    return {
      user: {
        username: "",
        password: "",
      },
    };
  },
  computed: {
    ...mapGetters({}),
  },
  methods: {
    ...mapActions({
      changeInfo: "changeInfo",
    }),
    login() {
      //验证
      reqLogin(this.user).then((res) => {
        //存用户信息
        this.changeInfo(res.data.list);
        //跳转页面
        this.$router.push("/");
      });
    },
  },
  mounted() {},
  props: [],
};
</script>
<style lang="less" scoped>
@import "../../less/index.less";
.login {
  width: 100vw;
  height: 100vh;
  background: linear-gradient(90deg, @primary, @info);
  position: relative;
}
.con {
  width: 300px;
  padding: @margin;
  background: #fff;
  border-radius: @margin;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.center {
  text-align: center;
}
.line {
  margin-bottom: @margin;
}
</style>